package com.oplink.webems.modules.alarm.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;

/**
 * Trap Oid Information Entity
 * @author yizhang
 */
@Entity
@Table(name = "trap_oid")
@DynamicInsert @DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class TrapOid {
	
	//ID
	private Long id;
	
	//Trap OID
	private String trapoid;
	
	//Trap Name
	private String trapname;
	
	//Trap Name in English
	private String engdesc;
	
	//Trap desc in Chinese
	private String description;
	
	List<TrapParam> plist = Lists.newArrayList(); 

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTrapoid() {
		return trapoid;
	}

	public void setTrapoid(String trapoid) {
		this.trapoid = trapoid;
	}

	public String getTrapname() {
		return trapname;
	}

	public void setTrapname(String trapname) {
		this.trapname = trapname;
	}

	public String getEngdesc() {
		return engdesc;
	}

	public void setEngdesc(String engdesc) {
		this.engdesc = engdesc;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE},fetch=FetchType.LAZY,mappedBy="trapoid")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)	
	@JsonIgnore	
	public List<TrapParam> getPlist() {
		return plist;
	}

	public void setPlist(List<TrapParam> plist) {
		this.plist = plist;
	}
}
